package com.example.g7640.controller;


import com.example.g7640.builder.ResultBuilder;
import com.example.g7640.dto.DeliveryQuery;
import com.example.g7640.dto.common.PageResult;
import com.example.g7640.dto.common.Result;
import com.example.g7640.entity.DeliveryInfo;
import com.example.g7640.service.impl.DeliveryInfoServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author
 * @since 2024-03-18
 */
@RestController
@RequestMapping("/api/dlvy-info")
public class DeliveryInfoController {

    @Resource
    DeliveryInfoServiceImpl deliveryInfoServiceImpl;

    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody DeliveryInfo deliveryInfo) {
        return ResultBuilder.buildSuccess(deliveryInfoServiceImpl.add(deliveryInfo));
    }

    @GetMapping("/del")
    public Result<Boolean> delete(Integer id) {
        return ResultBuilder.buildSuccess(deliveryInfoServiceImpl.delete(id));
    }

    @PostMapping("/set-dlvy-info-args")
    public Result<Boolean> set(@RequestBody DeliveryInfo deliveryInfo) {
        return ResultBuilder.buildSuccess(deliveryInfoServiceImpl.set(deliveryInfo));
    }

    @PostMapping("/get-list")
    public PageResult<List<DeliveryInfo>> getList(@RequestBody DeliveryQuery deliveryQuery) {
        return deliveryInfoServiceImpl.getList(deliveryQuery);
    }

    @GetMapping("/get-info")
    public Result<DeliveryInfo> getInfo(Integer id) {
        return ResultBuilder.buildSuccess(deliveryInfoServiceImpl.getInfo(id));
    }
}
